using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Skywave.Windows.Forms
{
    [Serializable()]
    public class SheetColumn
    {
        private Font mFont;
        private Color mForeColor, mBackColor;
        private ContentAlignment mTextAlign;
        private int mWidth = -1;
        private bool mRightToLeft = false;
        private bool mShrinkToFit = false;
        private bool mWarp = false;
        private bool mVerticalText = false;
        private System.Collections.ArrayList changedProps = new System.Collections.ArrayList();
        private SheetBorder mBorder = new SheetBorder();

        public int GetBorder(SheetBorderTypes type)
        {
            return mBorder[type];
        }
        public void SetBorder(SheetBorderTypes type, int value)
        {
            mBorder[type] = value;
        }

        public Font Font
        {
            get { return mFont; }
            set { mFont = value; }
        }

        public Color ForeColor
        {
            get { return mForeColor; }
            set { mForeColor = value; }
        }

        public Color BackColor
        {
            get { return mBackColor; }
            set { mBackColor = value; }
        }

        public ContentAlignment TextAlign
        {
            get { return mTextAlign; }
            set { mTextAlign = value; }
        }

        public bool RightToLeft
        {
            get { return mRightToLeft; }
            set { mRightToLeft = value; AddChangedProperty("RightToLeft"); }
        }

        public bool ShrinkToFit
        {
            get { return mShrinkToFit; }
            set
            {
                mShrinkToFit = value;
                if (value) mWarp = false;
                AddChangedProperty("ShrinkToFit");
            }
        }

        public bool VerticalText
        {
            get { return mVerticalText; }
            set { mVerticalText = value; AddChangedProperty("VerticalText"); }
        }

        public bool Warp
        {
            get { return mWarp; }
            set
            {
                mWarp = value;
                if (value) mShrinkToFit = false;
                AddChangedProperty("Warp");
            }
        }

        private void AddChangedProperty(string pName)
        {
            pName = pName.ToLower();
            if (changedProps.IndexOf(pName) == -1) changedProps.Add(pName);
        }

        public bool IsPropertyChanged(string pName)
        {
            pName = pName.ToLower();
            if (changedProps.IndexOf(pName) != -1) return true; else return false;
        }

        public int Width
        {
            get { return mWidth; }
            set { mWidth = value; }
        }
    }
}
